package jblip.resources;

import java.io.Serializable;

/**
 * <i>Transport</i> resource interface.
 * 
 * <p>
 * <i>Transport</i> is an object containing information of interface used to
 * post a message.
 * </p>
 * 
 * @author Krzysztof Sroka
 * @since 0.1
 */
public class Transport implements Serializable {
  private static final long serialVersionUID = 1L;

  public final static Transport EMAIL;

  public final static Transport SMS;

  public final static Transport JABBER;

  public final static Transport UNKNOWN;

  public final static Transport GADUGADU;

  public final static Transport WWW;

  public final static Transport API;

  static {
    EMAIL = new Transport(1, "E-mail");
    SMS = new Transport(2, "SMS");
    JABBER = new Transport(3, "Jabber");
    UNKNOWN = new Transport(4, "?");
    GADUGADU = new Transport(5, "Gadu-Gadu");
    WWW = new Transport(6, "WWW");
    API = new Transport(7, "API");
  }

  public static Transport getStandardTransport(Integer id) {
    switch (id) {
    case 1:
      return EMAIL;
    case 2:
      return SMS;
    case 3:
      return JABBER;
    case 4:
      return UNKNOWN;
    case 5:
      return GADUGADU;
    case 6:
      return WWW;
    case 7:
      return API;
    default:
      return null;
    }
  }

  private final String transport_name;

  private final Integer transport_id;

  protected Transport(final Integer id, final String name) {
    this.transport_id = id;
    this.transport_name = name;
  }

  /**
   * Get transport's ID.
   * 
   * @return ID of this resource.
   */
  public Integer getID() {
    return this.transport_id;
  }

  /**
   * Get transport's name.
   * 
   * <p>
   * Transport's name is a short textual description of it, suitable for viewing
   * in user interface.
   * </p>
   * 
   * @return Name of this resource.
   */
  public String getName() {
    return this.transport_name;
  }
  
  @Override
  public String toString() {
    return getName();
  }
}
